import { Entity, EntityCollection } from "cesium";
import { getViewer, nextTick } from "yt-cesium";

export function createEntity(
  entityOpt: Entity.ConstructorOptions,
  entityCollection?: EntityCollection
) {
  return nextTick().then(() => {
    if (!entityCollection) {
      entityCollection = getViewer().entities;
    }
    entityCollection.add(entityOpt);
  });
}